﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PlatformFramework.BaseFramework;
using DataModel;

namespace EsWebUI.Controllers
{
    public class ErrorHandController : BaseControl
    {
        //
        // GET: /ErrorHand/

        public ActionResult Index()
        {
            return View(new UserInfo());
        }

        [HttpPost]
        public ActionResult Index(UserInfo uf)
        {
            if (!ModelState.IsValid)
            {
                return this.View(new UserInfo { UserName = uf.UserName});
            }

            if (uf.UserName != "Foo")
            {
                throw new EsWebUI.Models.Error.InvalidUserNameException();
            }

            if (uf.UserID != "password")
            {
                throw new EsWebUI.Models.Error.UserNamePasswordNotMatchException();
            }

            ViewBag.Message = "Authentication Succeeds!";
            return this.View(new UserInfo { UserName = uf.UserName });
        }
        
    }
}
